home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d998.lha
/
TeXPrt
/
source
/
Process.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-05
|
12KB
|
248 lines
/***************************************************************************
* *
* Filename : Process.c *
* *
* Description : Processing routines for user inputs. *
* *
***************************************************************************
* *
* Modification History *
* *
* Date Author Comments *
* ---------------------------------------------------------------------- *
* 10.6.93 R.Bödi Created. *
* 21.2.94 R.Bödi Changed event loop for MUI. *
* *
***************************************************************************
* *
* Copyright © 1993 Richard Bödi, All rights reserved. *
* *
***************************************************************************/
/*----------------------------- INCLUDES ----------------------------------*/
#include "TeXPrt.h"
#include "TexPrt_protos.h"
#include "TexPrt_globals.h"
/*-------------------------- GLOBAL DATA ----------------------------------*/
static struct FileRequester *FileRequester;
static char *SaveAsTxt = "Save spec file as";
struct Status Status = { FALSE, FALSE, FALSE };
/*------------------------------- CODE ------------------------------------*/
/***************************************************************************
* *
* Function name : ProcessIDCMP *
* *
* Description : Tests window's IDCMP port for incoming messages. *
* This function returns if the window close gaget or the *
* CANCEL gadget was activated. *
* *
***************************************************************************
* *
* Synopsis : ProcessIDCMP (Structures, NonMUISignals) *
* *
* Parameters : *
* (struct StructPointers *) Structures: *
* Contains pointers to various data pools. *
* (long) NonMUISignals: *
* Contains signal bits that doesn't belong to the MUI. *
* *
* Return value : None *
* *
***************************************************************************/
void ProcessIDCMP (struct StructPointers *Structures, long NonMUISignals)
{
long SignalArrived = 0, MUISignal = 0;
USHORT Line;
ULONG Action;
char Buffer[FMSIZE];
struct AppMessage *AMsg;
struct TagItem FReqTags[4];
while (!Status.Exit)
{
switch (Action = DoMethod (Structures->MUIPointers->app, MUIM_Application_Input, &MUISignal))
{
case ID_SAVE:
if (!SaveDriverSpec (Structures->AvailDrivers->DriverFiles + Structures->DriverNumber * NAMELENGTH,
Structures->TeXDriver, Structures->RawSettings, Structures->DefaultSettings,
Structures->MUIPointers))
EasyRequest (Structures->MUIPointers->MainWindow, &SaveErrorReq, &IDCMPFlag,
Structures->AvailDrivers->DriverFiles + Structures->DriverNumber * NAMELENGTH);
break;
case ID_SAVEAS:
FReqTags[0].ti_Tag = ASL_File;
FReqTags[0].ti_Data = (ULONG)Structures->AvailDrivers->DriverFiles + Structures->DriverNumber * NAMELENGTH;
FReqTags[1].ti_Tag = ASL_Dir;
FReqTags[1].ti_Data = (ULONG)DriverDrawer;
FReqTags[2].ti_Tag = ASL_Hail;
FReqTags[2].ti_Data = (ULONG)SaveAsTxt;
FReqTags[3].ti_Tag = TAG_DONE;
if (FileRequester = MUI_AllocAslRequest (ASL_FileRequest, FReqTags))
if (MUI_AslRequest (FileRequester, NULL))
{
if (!SaveDriverSpec (FileRequester->rf_File, Structures->TeXDriver, Structures->RawSettings,
Structures->DefaultSettings, Structures->MUIPointers))
EasyRequest (Structures->MUIPointers->MainWindow, &SaveErrorReq, &IDCMPFlag, FileRequester->rf_File);
MUI_FreeAslRequest (FileRequester);
}
break;
case ID_ABOUT:
EasyRequest (Structures->MUIPointers->MainWindow, &AboutReq, &IDCMPFlag, &Version[6]);
break;
case ID_PRINT:
if (Structures->ARexxAvailable)
system (RexxPrintMacro);
else
CallPrinterDriver (Structures, FALSE);
break;
case ID_PRINTAREXX:
CallPrinterDriver (Structures, FALSE);
break;
case ID_FROM_PAGE:
case ID_TO_PAGE:
SetAttrs (Structures->MUIPointers->RAD_FromTo, MUIA_Radio_Active, FROMTO, TAG_DONE);
break;
case ID_TOFRONT:
DoMethod (Structures->MUIPointers->MainWindow, MUIM_Window_ToFront, TRUE);
break;
case ID_SCREENTOFRONT:
DoMethod (Structures->MUIPointers->MainWindow, MUIM_Window_ScreenToFront, TRUE);
break;
case ID_TOBACK:
DoMethod (Structures->MUIPointers->MainWindow, MUIM_Window_ToBack, TRUE);
break;
case ID_SCREENTOBACK:
DoMethod (Structures->MUIPointers->MainWindow, MUIM_Window_ScreenToBack, TRUE);
break;
case ID_QUIT:
Status.Exit = TRUE;
break;
case MUIV_Application_ReturnID_Quit:
Status.Exit = Status.ARexx = TRUE;
break;
}
if ((Action >= ID_DRIVER) && (Action <= (ID_DRIVER + Structures->AvailDrivers->NoOfDrivers)))
{
if (Line = LoadDriverSpec (Structures, Action - ID_DRIVER))
EasyRequest (Structures->MUIPointers->MainWindow, &LoadErrorReq, &IDCMPFlag,
Structures->AvailDrivers->DriverFiles + (Action - ID_DRIVER) * NAMELENGTH, Line);
else
UpdateGUI (Structures->MUIPointers, Structures->DefaultSettings, Structures->ParsedSettings);
}
if (SignalArrived & NonMUISignals)
while (AMsg = (struct AppMessage *)GetMsg (AppMsgPort))
{
Status.ARexx = FALSE;
switch (AMsg->am_Type)
{
case MTYPE_APPICON:
if (AMsg->am_NumArgs == 0)
Status.Exit = !EasyRequest (NULL, &AppIconReq, &IDCMPFlag, NULL);
else
{
NameFromLock (AMsg->am_ArgList->wa_Lock, Buffer, sizeof (Buffer));
strmfp (Args.ArgStr[KW_FILE], Buffer, AMsg->am_ArgList->wa_Name);
SetAttrs (Structures->MUIPointers->STR_DVIFile, MUIA_String_Contents, Args.ArgStr[KW_FILE], TAG_DONE);
}
break;
}
ReplyMsg ((struct Message *)AMsg);
}
if (Status.Exit & !Status.ARexx)
Status.Exit = EasyRequest (Structures->MUIPointers->MainWindow, &QuitReq, &IDCMPFlag, NULL);
else
if ((!Status.Exit) && (MUISignal)) SignalArrived = Wait (MUISignal | NonMUISignals);
Status.ARexx = FALSE;
}
}
/***************************************************************************
* *
* Function name : UpdateGUI *
* *
* Description : Updates the GUI with the corresponding values of the *
* TeXDriver structure. *
* *
***************************************************************************
* *
* Synopsis : UpdateGUI (Pointers, Default) *
* *
* Parameters : *
* (struct MUIPointers *) Pointers: *
* A structure consisting of APTRs to MUI elements. *
* (struct DefaultSettings *) Default: *
* Contains the settings for updating the GUI. *
* (struct ParsedSettings *) Parsed: *
* Contains the aprsed command line parameters. *
* *
* Return value : None *
* *
***************************************************************************/
void UpdateGUI (struct MUIPointers *Pointers, struct DefaultSettings *Default, struct ParsedSettings *Parsed)
{
int OptionCount;
BOOL Disabled;
SetAttrs (Pointers->STR_OutFile, MUIA_String_Contents, Default->DeviceName, TAG_DONE);
SetAttrs (Pointers->STR_Copies, MUIA_String_Integer, Default->Copies, TAG_DONE);
SetAttrs (Pointers->STR_X, MUIA_String_Integer, Default->HOffset, TAG_DONE);
SetAttrs (Pointers->STR_Y, MUIA_String_Integer, Default->VOffset, TAG_DONE);
SetAttrs (Pointers->RAD_FromTo, MUIA_Radio_Active, Default->PageSel, TAG_DONE);
SetAttrs (Pointers->RAD_OddEven, MUIA_Radio_Active, Default->PageType, TAG_DONE);
SetAttrs (Pointers->RAD_Orientation, MUIA_Radio_Active, Default->Orientation, TAG_DONE);
SetAttrs (Pointers->TXT_X, MUIA_Text_Contents, Parsed->HOffsetTxt, TAG_DONE);
SetAttrs (Pointers->TXT_Y, MUIA_Text_Contents, Parsed->VOffsetTxt, TAG_DONE);
Disabled = Parsed->Device[0] == ' ' ? TRUE : FALSE;
SetAttrs (Pointers->IMG_Out, MUIA_Disabled, Disabled, TAG_DONE);
Disabled = Parsed->OddPages[0] == ' ' ? TRUE : FALSE;
SetAttrs (Pointers->RAD_OddEven, MUIA_Disabled, Disabled, TAG_DONE);
Disabled = ((Parsed->Portrait[0] = ' ') && (Parsed->LandScape[0] == ' ')) ? TRUE : FALSE;
SetAttrs (Pointers->RAD_Orientation, MUIA_Disabled, Disabled, TAG_DONE);
Disabled = Parsed->HOffset[0] == ' ' ? TRUE : FALSE;
SetAttrs (Pointers->STR_X, MUIA_Disabled, Disabled, TAG_DONE);
Disabled = Parsed->VOffset[0] == ' ' ? TRUE : FALSE;
SetAttrs (Pointers->STR_Y, MUIA_Disabled, Disabled, TAG_DONE);
for (OptionCount = 0; OptionCount < OPTIONS; OptionCount++)
{
SetAttrs (Pointers->CHM_Option[OptionCount], MUIA_Selected, Default->Option[OptionCount], TAG_DONE);
SetAttrs (Pointers->TXT_Option[OptionCount], MUIA_Text_Contents, Parsed->OptionTxt[OptionCount], TAG_DONE);
Disabled = Parsed->Option[OptionCount][0] == ' ' ? TRUE : FALSE;
SetAttrs (Pointers->CHM_Option[OptionCount], MUIA_Disabled, Disabled, TAG_DONE);
}
}
/*---------------------------- END OF FILE --------------------------------*/